package com.bj.boot.config;

import com.bj.boot.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 要使用自己编写的拦截器LoginInterceptor
 * 把拦截器注册到容器中（使用WebMvcConfigurer的addInterceptors方法）
 */

@Configuration
public class AdminWebConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptor()).
                addPathPatterns("/**").//所有请求都被拦截包括静态资源
                excludePathPatterns("/","/login","/css/**","/fonts/**","/images/**","/js/**","/sql");
                //访问此处设置的放行路径时，将不会进入LoginInterceptor的preHandle方法，从而不被拦截

    }
    //@Bean
    //public WebMvcRegistrations webMvcRegistrations(){
    //    return new WebMvcRegistrations(){
    //        public
    //    };
    //}
}
